# -*- coding: utf-8 -*-
# @Time    : 2019/10/14 19:17
# @Author  : LiHaowen
# @Email   : lihaowen2017@163.com
# @File    : duck_type.py

# python多态性，不同类实现相同的方法，体现了鸭子类型。python的魔法函数也体现了鸭子类型。


class Cat(object):
    def say(self):
        print("i am a cat")


class Dog(object):
    def say(self):
        print("i am a dog")


class Duck(object):
    def say(self):
        print("i am a duck")


# animal = Cat
# animal().say()

animal_list = [Cat, Dog, Duck]
for animal in animal_list:
    animal().say()




